﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CoreEx.Common.Proxy;
using LinFu.IoC.Configuration;
using Mono.Cecil;

namespace CoreEx.Common.Tests
{
    [Implements(typeof(ITypeModifier),ServiceName = "SampleTypeModifier")]
    public class SampleTypeModifier : ITypeModifier
    {
        public void BeforeConstruction(Type originalBaseType, IEnumerable<Type> baseInterfaces, ModuleDefinition module, TypeDefinition targetType)
        {
            
        }

        public void AfterConstruction(Type originalBaseType, IEnumerable<Type> baseInterfaces, ModuleDefinition module, TypeDefinition targetType)
        {                        
            MethodReference methodReference =  
                targetType.Module.Import(typeof (SampleAttribute).GetConstructor(new Type[] {}));
            
            targetType.CustomAttributes.Add(new CustomAttribute(methodReference));
        }
    }
}
